package com.luguokong.pet_rescue.mapper;

import com.luguokong.pet_rescue.pojo.Adopt;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface AdoptMapper {
    public int insertAdopt(Adopt adopt);
    public int deleteAdoptById(int adopt_id);
    public int updateAdoptById(Adopt adopt);
    public Adopt selectAdoptById(int adopt_id);
    public List<Adopt> selectAdoptAll();
    public List<Adopt> selectAdoptAllByUserId(int user_id);

    @Select("select * from adopt limit #{pageNum},#{pageSize}")
    public List<Adopt> selectAdoptAllByPageNumByPageSize(int pageNum, int pageSize);

    @Select("select count(*) from adopt")
    public int selectDataCount();

    @Select("SELECT pet_type as 'name', count(adopt_id) as 'value' from pets " +
            "INNER JOIN adopt " +
            "ON pets.pet_id = adopt.pet_id " +
            "GROUP BY pet_type")
    public List<Map<String, Number>> selectGroupByPetType();
}
